package com.atguyigu.codesday02;


import java.util.concurrent.TimeUnit;

class MyNumber{
int  number = 0;
public  int getNumber(){
    return number;
}
 public synchronized void setNumber(){
    number++;
    number--;
 }

}

public class CASDemo1 {
    public static void main(String[] args) {
        MyNumber myNumber = new MyNumber();

        for (int i = 1; i <=200 ; i++) {
           new Thread( ()->{
               for (int j = 1; j <=200 ; j++) {
                   myNumber.setNumber();
           }  },String.valueOf(i)).start();

            try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace();
                System.out.println(myNumber.getNumber());
            }
        }
    }






}
